import java.io.*;

/*
ID: qingtia2
LANG: JAVA
TASK: beads
*/
class beads {

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new FileReader("beads.in"));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("beads.out")));
        Integer n = Integer.parseInt(in.readLine());
        String str = in.readLine();
        int count = 2;
        int len = 0;
        int num = n;
        String newStr = str + str;
        int countW = 0;
        for (int i = 0; i < n; i++) {
            StringBuilder s = new StringBuilder("" + newStr.charAt(i));
            if ('w' == newStr.charAt(i)) {
                countW++;
                continue;
            }
            int total = i;
            while (true) {
                num--;
                if (count == 0 || num == 0) {
                    len = Math.max(len, s.length() + countW);
                    count = 2;
                    break;
                }
                if (newStr.charAt(total + 1) == 'w' || newStr.charAt(total + 1) == s.charAt(s.length() - 1)) {
                    s.append(s.charAt(s.length() - 1));
                } else {
                    if (--count == 0) continue;
                    else s.append(newStr.charAt(total + 1));
                }
                total++;
            }
            if (num == 0) {
                break;
            }
            num = n;
            countW = 0;
        }
        out.println(len == 0 ? n : len);
        out.close();
    }
}
